package com.fuxin.mywiki.resp;

import com.fuxin.mywiki.domain.Ebook;
import com.fuxin.mywiki.service.EbookService;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;


public class CommonResp<T> {

    /**
     * 业务上的成功或失败
     */
    private boolean success = true;

    /**
     * 返回信息
     */
    private String message;

    /**
     * 返回泛型数据，自定义类型
     */
    private T content;
    private EbookService ebookService;

    public boolean getSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getContent() {
        return content;
    }

    public void setContent(T content) {
        this.content = content;
    }

    @Override
    public String toString() {
        String sb = "ResponseDto{" + "success=" + success +
                ", message='" + message + '\'' +
                ", content=" + content +
                '}';
        return sb;
    }

    @GetMapping("/list")
    public CommonResp list() {
        CommonResp<List<Ebook>> resp = new CommonResp<>();
        List<Ebook> list = ebookService.list();
        resp.setContent(list);
        return resp;
    }
}